//package com.lagou.edu.servlet;
//
//import com.lagou.edu.pojo.Account;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//
///**
// *  登录的servlet
// *  从 登录的 html中过来的数据
// */
//public class LoginServlet extends HttpServlet {
//
//    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        response.setContentType("text/html;charset=UTF-8");
//        PrintWriter out = response.getWriter();
//        String username=request.getParameter("userName");
//        String password=request.getParameter("passWord");
//        Account user=DB.find(username, password);
//        if(user==null)
//        {
//            out.write("登录账号密码错误");
//            return;
//        }
//        //接下里是进行保存到本地
//        request.getSession().setAttribute("user", user); //向用户session中存一个登陆标记，也就是让用户登陆成功
//        //重定向 指向刚才的 登录html
//        response.sendRedirect("/Demo2/Login.jsp");
//    }
//
//    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        doGet(request, response);
//    }
//
//    //数据库  模拟
//    static class  DB{
//        private static List<User> list = new ArrayList<User>();
//        static{
//            list.add(new User("aaa","123"));
//            list.add(new User("bbb","123"));
//            list.add(new User("ccc","123"));
//        }
//        public static User find(String username ,String password){
//            for(User user : list){
//                if(user.getName().equals(username) && user.getPassword().equals(password)){
//                    return user;
//                }
//            }
//            return null;
//        }
//    }
//
//}